#include<bits/stdc++.h>
using namespace std;
class Time
{
private:
	int hour;
	int minute;
	int second;
	Time add(const Time& t, int s);
public:
	Time()
	{
		hour = minute = second = 0;
	}
	Time(int h,int m,int s)
	{
		if(h<24 && h>=0 && m<60&&m>=0&&s<60&&s>=0)
		{
			hour = h;
			minute = m;
			second = s;
		}
		else
		{
			cout<<"wrong time\n";
			hour = minute = second = 0;
		}
	}
	Time(int s)
	{
		if(s < 0)
		{
			cout<<"wrong time\n";
			hour = minute = second = 0;
		}
		s %= 24*3600;
		hour = s / 3600;
		minute = (s-hour*3600) / 60;
		second = s - hour*3600 - minute * 60;
	}
	Time operator+(int s);
	Time operator-(int s);
	friend Time operator+(int s, const Time& t);
	friend Time operator-(int s, const Time& t);
	Time operator++();
    Time operator++(int);
    Time operator--();
    Time operator--(int);
	friend ostream& operator<<(ostream& out,const Time& t);
	
};
Time Time::add(const Time& t, int s)
{
	if(s < 0)
	{
		s += (-s / (24*3600)+1) * 24*3600;
		s %= 24*3600;
	}
	int news= t.hour*3600+t.minute*60+t.second + s;
	Time ans(news);
	return ans;
}
Time Time::operator+(int s)
{
	return add(*this, s);
}
Time operator+(int s, const Time& t)
{
	Time ans;
	return ans.add(t, s);
}
Time operator-(int s, const Time& t)
{
	int CalSec = t.hour*3600 + t.minute*60 + t.second;
	CalSec = s-CalSec;
	if(CalSec < 0)
	{
		CalSec += (-CalSec / (24*3600) + 1) * 24*3600;
	}
	Time ans(CalSec);
	return ans;
}
Time Time::operator-(int s)
{
	return add(*this, -s);
}
Time Time::operator++()
{
	*this = *this+1;
	return *this;
}
Time Time::operator++(int)
{
	Time ans = *this;
	*this = *this+1;
	return ans;
}
Time Time::operator--()
{
	*this = *this-1;
	return *this;
}
Time Time::operator--(int)
{
	Time ans = *this;
	*this = *this - 1;
	return ans;
}

ostream& operator<<(ostream& out, const Time& t)
{
	out<<setw(2)<<setfill('0')<<t.hour<<":";
	out<<setw(2)<<setfill('0')<<t.minute<<":";
	out<<setw(2)<<setfill('0')<<t.second;
	return out;
}
int main()
{
	Time time1(55,17,46) ,time2(10,20,30);
	cout<<time1<<endl;
	Time time3 = time1 + 4251;
	Time time4 = time1 - 222561;
	cout<<time3<<endl;
	cout<<time4<<endl;

	cout<<time1++<<endl;
	cout<<++time1<<endl;

	cout<<time1--<<endl;
	cout<<--time1<<endl;

	cout<<222561+ time1<<endl;
	cout<<1 - time1<<endl;
	return 0;
}